package com.xu.cloud.auth.service.impl;

import com.xu.cloud.auth.component.TokenComponent;
import com.xu.cloud.auth.service.LogoutService;
import com.xu.cloud.common.util.AssertUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * logout service implement
 *
 * @author xuguan
 * @since 2025/2/27
 */
@Service
@Slf4j
public class LogoutServiceImpl implements LogoutService {

    @Autowired
    private TokenComponent tokenComponent;

    @Override
    public void logout(String accessToken) {
        log.info("退出登录开始, accessToken={}", accessToken);
        AssertUtil.assertHasText(accessToken);
        tokenComponent.deleteAccessToken(accessToken);
        log.info("退出登录成功");
    }
}
